import re


def is_valid_ipv4(ip: str) -> bool:
    match_str = r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
    if re.match(match_str, ip):
        return True
    return False


def is_valid_ipv6(ip: str) -> bool:
    match_str = r"^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$"
    if re.match(match_str, ip):
        return True
    return False


def is_valid_ip(ip: str) -> bool:
    if not is_valid_ipv6(ip) and not is_valid_ipv4(ip):
        return False
    return True
